#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>


typedef struct BinaryTreeNode {
    char data;
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
}BTNode;

BTNode* BuyNode(char x)
{
    BTNode* root = (BTNode*)malloc(sizeof(BTNode));
    root->left = root->right = NULL;
    root->data = x;
    return root;
}

BTNode* BinaryTreeCreate(char* arr, int* pi)
{
    if (arr[*(pi)] == '#')
    {
        *(pi)++;
        return NULL;
    }
    BTNode* root = BuyNode(arr[*(pi)]);
    (*pi)++;
    root->left = BinaryTreeCreate(arr, pi);
    root->right = BinaryTreeCreate(arr, pi);

    return root;
}

void inOrder(BTNode* root)
{
    if (root == NULL)
    {
        return;
    }
    inOrder(root->left);
    printf("%c ", root->data);
    inOrder(root->right);

}
int main()
{
    char arr[100];
    scanf("%s", arr);
    int pi = 0;
    BTNode* root = BinaryTreeCreate(arr, &pi);

    inOrder(root);
    return 0;
}